import { Global, Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import * as Minio from 'minio'
export const MINIO_CLIENT = 'MINIO_CLIENT'
@Global()
@Module({
  providers: [
    {
      provide: MINIO_CLIENT,
      async useFactory(configService: ConfigService) {
        const client = new Minio.Client({
          // endPoint: configService.get('minio_endPoint'),
          endPoint: 'localhost',
          port: Number(configService.get('minio_port')),
          useSSL: false,
          accessKey: configService.get('minio_accessKey'),
          secretKey: configService.get('minio_secretKey')
        })
        return client
      },
      inject: [ConfigService]
    }
  ],
  exports: [MINIO_CLIENT]
})
export class MinioModule {}
